package Cn.Sarkar.MMS.LayerOne

import Cn.Sarkar.MMS.DataBaseDefinations.Independent.ApplicationDomains
import Cn.Sarkar.MMS.Entities.Additional.Description
import Cn.Sarkar.MMS.Entities.Additional.Name
import Cn.Sarkar.MMS.Entities.DataSources.IDataSource
import Cn.Sarkar.MMS.Entities.Independent.Application
import Cn.Sarkar.MMS.Entities.Independent.ApplicationDomain
import Cn.Sarkar.MMS.LayerOne.Repositories.findAndStoreIfNotExists

object EntityBuilder {
    private fun makeAppName(dataContext: IDataSource): Name {
        val _name = Name(dataContext).apply {
            ug = "سەركار ئەزا باشقۇرۇش سىستېمىسى"
            en = "Sarkar member management system"
            zh = "彩科成员管理系统"
            ru = "Sarkar member management system"
            kz = "سەركار ئەزا باشقۇرۇش سىستېمىسى"
            category = ApplicationDomains.CATEGORY
        }
        return dataContext.findAndStoreIfNotExists(_name)
    }

    private fun makeAppDescription(dataContext: IDataSource): Description {
        val _description = Description(dataContext).apply {
            ug = "سەركار ئەزا باشقۇرۇش سىستېمىسى"
            en = "Sarkar member management system"
            zh = "彩科成员管理系统"
            ru = "Sarkar member management system"
            kz = "سەركار ئەزا باشقۇرۇش سىستېمىسى"
            category = ApplicationDomains.CATEGORY
        }
        return dataContext.findAndStoreIfNotExists(_description)
    }

    fun makeApplicationDomain(dataContext: IDataSource): ApplicationDomain {
        val domain = ApplicationDomain(dataContext).apply {
            name = makeAppName(dataContext)
            description = makeAppDescription(dataContext)
        }
        return domain
    }


    fun makeApplication(dataContext: IDataSource): Application {
        val app = Application(dataContext).apply {
            name = makeAppName(dataContext)
            description = makeAppDescription(dataContext)
        }
        return app
//        defaultMemberShipLevel = JMemberShipLevel().apply {
//            name = JName().apply {
//                ug = "سۈكۈتتىكى ئەزا دەرىجىسى"
//                en = "default membership level"
//                zh = "默认的用户级别"
//                ru = "default membership level"
//                kz = "سۈكۈتتىكى ئەزا دەرىجىسى"
//                category = MemberShipLevels.CATEGORY
//            }
//            description = JDescription().apply {
//                ug = "سۈكۈتتىكى ئەزا دەرىجىسى"
//                en = "default membership level"
//                zh = "默认的用户级别"
//                ru = "default membership level"
//                kz = "سۈكۈتتىكى ئەزا دەرىجىسى"
//                category = MemberShipLevels.CATEGORY
//            }
//
//        }
    }
}